﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;
using MusicPlayerLib.Utils;
using MusicPlayerLib.DataModel;
using System.IO;
using System.Xml.Serialization;
using System.Diagnostics;
namespace NewPanda
{
    /// <summary>
    /// Window1.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        private bool isMusicPanelVisible;

        public MainWindow()
        {
            InitializeComponent();
            isMusicPanelVisible = true;
        }

        /*
        private void MusicButton_Click(object sender, RoutedEventArgs e)
        {
            if (!isMusicPanelVisible)
            {
                tran_Container.ApplyTransition("p2p", "music");
                isMusicPanelVisible = !isMusicPanelVisible;
            }
        }

        private void P2PButton_Click(object sender, RoutedEventArgs e)
        {
            if (isMusicPanelVisible)
            {
                tran_Container.ApplyTransition("music","p2p");
                isMusicPanelVisible = !isMusicPanelVisible;
            }
        }
         * */

        private void LibIn_Click(object sender, RoutedEventArgs e) 
        {
            System.Windows.Forms.FolderBrowserDialog folderOpenFile = new System.Windows.Forms.FolderBrowserDialog();
            folderOpenFile.Description = "请选择音乐所在文件夹";
            DialogResult result = folderOpenFile.ShowDialog();
           
                string folderName = folderOpenFile.SelectedPath;
                Debug.WriteLine(folderName);
                if (folderName != "")
                {
                    DirectoryInfo[] dirs = new DirectoryInfo(folderName).GetDirectories();
                    

                    MediaLibrary library = MusicPlayerUtils.GenerateMediaLibrary(dirs);

                    XmlSerializer xs = new XmlSerializer(typeof(MediaLibrary));

                    FileStream fs = new FileStream(@"D:\test.xml", FileMode.OpenOrCreate);
                    xs.Serialize(fs, library);

                }
        }
        private void LibAd_Click(object sender, RoutedEventArgs e) 
        {

        }
    }
}
